﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using DTOAuction;
using System.Configuration;

namespace DAOAuction
{
    public class DAOMonHoc
    {
        // lấy danh sách các môn học có mã khoa:
        public List<MONHOC> layDanhSachMonHocVoiMaKhoa(int maKhoa)
        {
            List<MONHOC> lstMonHoc = new List<MONHOC>();
            using (LinqDataContext db = new LinqDataContext(global::DAOAuction.Properties.Settings.Default.QUANLYGIAODUCConnectionString))
            {

                ISingleResult<MONHOC_getallwithMaKhoaResult> lp = db.MONHOC_getallwithMaKhoa(maKhoa);
                foreach (MONHOC_getallwithMaKhoaResult MONHOC in lp)
                {
                    MONHOC var1 = new MONHOC();
                    var1.MAMONHOC = MONHOC.MAMONHOC;
                    var1.TENMONHOC = MONHOC.TENMONHOC;
                    var1.MAKHOA = MONHOC.MAKHOA;
                    var1.SOTINCHI = MONHOC.SOTINCHI;
                    var1.HOCKIMO = MONHOC.HOCKIMO;
                    lstMonHoc.Add(var1);
                }
                try
                {
                    // Save the changes.
                    db.SubmitChanges();
                }
                // Detect concurrency conflicts.
                catch (ChangeConflictException)
                {
                    // Resolve conflicts.
                    db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
                }
            }
            return lstMonHoc;
        }
    }
}
